/*----------------------------------------------------------------------
  - File name      : SCCB.h
  - Author         : Liu Chao
  - Update date    : 2020-07-14                   
  -	Copyright      : Gevico Electronic studio   
  - Module comments: 
-----------------------------------------------------------------------*/
#ifndef __SCCB_H_
#define __SCCB_H_
/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/

#include "main.h"
#include "gpio.h"

/*-----------------------------------------------------------------------
|                                 DATA                                  |
-----------------------------------------------------------------------*/


//--SCCB-----------------------------------------------------------

/*-----SCL SDA  GPIO Pin define-----*/

#define   SCCB_GPIO_CLK_ENABLE()   __HAL_RCC_GPIOB_CLK_ENABLE()

#define   SCCB_SCL_GPIO     GPIOB
#define   SCCB_SDA_GPIO     GPIOB
#define   SCCB_SCL_PIN      GPIO_PIN_6
#define   SCCB_SDA_PIN      GPIO_PIN_7

/*-----SCL SDA  work define-----*/

#define SCL_H   HAL_GPIO_WritePin(SCCB_SCL_GPIO,SCCB_SCL_PIN,GPIO_PIN_SET)
#define SCL_L HAL_GPIO_WritePin(SCCB_SCL_GPIO,SCCB_SCL_PIN,GPIO_PIN_RESET)

#define SDA_H   HAL_GPIO_WritePin(SCCB_SDA_GPIO,SCCB_SDA_PIN,GPIO_PIN_SET)
#define SDA_L HAL_GPIO_WritePin(SCCB_SDA_GPIO,SCCB_SDA_PIN,GPIO_PIN_RESET)

#define Scl_READ HAL_GPIO_ReadPin(SCCB_SCL_GPIO , SCCB_SCL_PIN)
#define SDA_READ HAL_GPIO_ReadPin(SCCB_SDA_GPIO , SCCB_SDA_PIN)

#define SDA_IN()  {GPIOB -> MODER &= ~(3<<(7*2));GPIOB -> MODER |= 0<<7*2;}	//SDA in
#define SDA_OUT() {GPIOB -> MODER &= ~(3<<(7*2));GPIOB -> MODER |= 1<<7*2;} //SDA out
 
//--OV7725 define----------------------------------------------------

#define ADDR_OV7725    0x42

#define DEV_ADR ADDR_OV7725

/*-----------------------------------------------------------------------
|                             API FUNCTION                              |
-----------------------------------------------------------------------*/

void    SCCB_GPIO_Config(void);
uint8_t SCCB_Send_Byte(uint8_t Dat);
uint8_t SCCB_Receive_Byte(void);
uint8_t SCCB_Write_Reg(uint16_t Address ,uint8_t Dat);
uint8_t SCCB_Read_Reg(uint8_t Reg);

#endif

/*-----------------------------------------------------------------------
|          END OF FLIE        (C) COPYRIGHT Gevico Electronics          | 
-----------------------------------------------------------------------*/
